home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 376-400 / disk_376 / toollibrary / src / library_demo2.c < prev    next >
C/C++ Source or Header  |  1992-05-06  |  4KB  |  204 lines

  1.  #include <exec/types.h>
  2.  #include <proto/tool.h>
  3.  #include <exec/memory.h>
  4.  #include <graphics/gfxmacros.h>
  5.  #include <intuition/intuition.h>
  6.  #include <proto/exec.h>
  7.  #include <proto/dos.h>
  8.  #include <proto/intuition.h>
  9.  #include <proto/graphics.h>
  10.  #include <string.h>
  11.  #include <stdio.h>
  12.  #include <stdlib.h>
  13.  
  14.  LONG Open_All(VOID);
  15.  VOID Ende(VOID);
  16.  VOID main(VOID);
  17.  
  18.  struct IntuitionBase     *IntuitionBase;
  19.  struct GfxBase     *GfxBase;
  20.  struct Library     *ToolBase;
  21.  struct Screen         *Screen;
  22.  struct Window         *Window;
  23.  LONG MaxPos=11,MaxPos2=16;
  24.  
  25.  struct PropInfo PInfo=
  26.   {
  27.    FREEVERT|AUTOKNOB,0,MAXBODY/3,0,MAXBODY/3,0,0,0,0,0,0
  28.   };
  29.  struct PropInfo PInfo2=
  30.   {
  31.    FREEHORIZ|AUTOKNOB,MAXBODY/4,0,MAXBODY/4,0,0,0,0,0,0,0
  32.   };
  33.  
  34.  struct Image HImage;
  35.  struct Image HImage2;
  36.  
  37.  struct Gadget Pot =
  38.   {
  39.    NULL       ,15,11,20,120,GADGHCOMP,GADGIMMEDIATE|FOLLOWMOUSE,PROPGADGET,(APTR)&HImage,0,NULL,NULL,(APTR)&PInfo,1,0
  40.   };
  41.  
  42.  struct Gadget Pot2 =
  43.   {
  44.    &Pot       ,45,31,500,20,GADGHCOMP,GADGIMMEDIATE|FOLLOWMOUSE,PROPGADGET,(APTR)&HImage2,0,NULL,NULL,(APTR)&PInfo2,2,0
  45.   };
  46.  
  47.  
  48.  struct NewScreen Schirm=
  49.   {
  50.    0,0,640,256,2,2,1,HIRES,CUSTOMSCREEN,NULL,NULL,NULL,NULL
  51.   };
  52.  
  53.  struct NewWindow Fenster=
  54.   {
  55.    0,10,640,246,0,1,CLOSEWINDOW|GADGETDOWN|MOUSEMOVE,
  56.    BORDERLESS|ACTIVATE|WINDOWCLOSE,
  57.    &Pot2,NULL,NULL,
  58.    NULL,
  59.    NULL,
  60.    NULL,
  61.    NULL,
  62.    NULL,
  63.    NULL,
  64.    CUSTOMSCREEN
  65.   };
  66.  
  67.  UWORD Pattern[4]=
  68.   {
  69.    0xff00,0xff00,0x00ff,0x00ff
  70.   };
  71.  
  72.  LONG Open_All(VOID)
  73.   {
  74.    IntuitionBase=(struct IntuitionBase *)OpenLibrary("intuition.library",0);
  75.    if(!IntuitionBase)
  76.     {
  77.      Ende();
  78.      return(1);
  79.     }
  80.    
  81.    GfxBase=(struct GfxBase *)OpenLibrary("graphics.library",0);
  82.    if(!GfxBase)
  83.     {
  84.      Ende();
  85.      return(2);
  86.     }
  87.    ToolBase=OpenLibrary("tool.library",0);
  88.    if(!ToolBase)
  89.     {
  90.      Ende();
  91.      return(3);
  92.     }
  93.    
  94.    Screen=OpenScreen(&Schirm);
  95.    if(!Screen)
  96.     {
  97.      Ende();
  98.      return(5);
  99.     }
  100.    
  101.    Fenster.Screen=Screen;
  102.    
  103.    Window=OpenWindow(&Fenster);
  104.    if(!Window)
  105.     {
  106.      Ende();
  107.      return(6);
  108.     }
  109.    
  110.    return(0);
  111.   }
  112.  
  113.  VOID Ende(VOID)
  114.   {
  115.    
  116.    /* Wenn offen -> schließen */
  117.    if(Window)
  118.     {
  119.      CloseWindow(Window);
  120.      ClearMenuStrip(Window);
  121.     };
  122.    
  123.    if(Screen)CloseScreen(Screen);
  124.    
  125.    if(GfxBase)CloseLibrary((struct Library *)GfxBase);
  126.    
  127.    if(IntuitionBase)CloseLibrary((struct Library *)IntuitionBase);
  128.    if(ToolBase)CloseLibrary(ToolBase);
  129.    
  130.   }
  131.  
  132.  VOID _main()
  133.   {
  134.    LONG i,ENDE=1,Nr,a,aa,ai;
  135.    struct PropInfo *PInfo3;
  136.    struct RastPort *RP;
  137.    struct info msgInfo;
  138.    char buffer[90];
  139.    
  140.    PInfo3=&PInfo;
  141.    if(!Open_All())
  142.     {
  143.      RP=Window->RPort;
  144.      SetDrMd(RP,JAM2);
  145.      i=GetPropPosH(&Pot2,MaxPos2);
  146.      a=GetPropPosV(&Pot ,MaxPos);
  147.      sprintf(buffer,"Vert : %3ld                                   Horiz: %3ld",a,i);
  148.      Print(RP,buffer,1,10,150);
  149.      aa=a;
  150.      ai=i;
  151.      
  152.      while(ENDE)
  153.       {
  154.        Wait(1L<<Window->UserPort->mp_SigBit);
  155.        /* Arbeitet ab, bis keine Events mehr */
  156.        while(EventAbfrage(Window,&msgInfo))
  157.         {
  158.          /* Verzweigt entsprechend der Events */
  159.          switch(msgInfo.NachrichtenArt)
  160.           {
  161.            case CLOSEWINDOW:ENDE=0;
  162.            break;
  163.            case MOUSEMOVE:
  164.            case GADGETDOWN:
  165.             {
  166.              Nr=((struct Gadget *)msgInfo.IAddress)->GadgetID;
  167.              i=GetPropPosH(&Pot2,MaxPos2);
  168.              a=GetPropPosV(&Pot ,MaxPos);
  169.              SetPropPosH(&Pot2,Window,MaxPos2,4,i);
  170.              SetPropPosV(&Pot ,Window,MaxPos ,3,a);
  171.              if(aa!=a||ai!=i)
  172.               {
  173.                
  174.                sprintf(buffer,"Vert : %3ld                                   Horiz: %3ld",a,i);
  175.                Move(RP,10,150);
  176.                ClearEOL(RP);
  177.                Print(RP,buffer,1,10,150);
  178.                aa=a;
  179.                ai=i;
  180.               }
  181.             }
  182.           }
  183.         }
  184.       }
  185.      
  186.      for(i=0;i<=10;i++)
  187.       {
  188.        SetPropPosH(&Pot2,Window,MaxPos2,4,i);
  189.        SetPropPosV(&Pot ,Window,MaxPos ,3,i);
  190.        i=GetPropPosH(&Pot2,MaxPos2);
  191.        a=GetPropPosV(&Pot ,MaxPos);
  192.        sprintf(buffer,"Vert : %3ld                                   Horiz: %3ld",a,i);
  193.        Move(RP,10,150);
  194.        ClearEOL(RP);
  195.        Print(RP,buffer,1,10,150);
  196.        
  197.        Delay(50);
  198.       }
  199.      
  200.      Delay(50);
  201.      Ende();
  202.     }
  203.   }
  204.